package com.aaa.service.impl;

import cn.hutool.core.date.DateUnit;
import com.aaa.entity.Discuss;
import com.aaa.mapper.DiscussMapper;
import com.aaa.service.DiscussService;
import com.aaa.util.DefaultMsg;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import javax.xml.crypto.Data;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

@Service
public class DiscussServiceImpl implements DiscussService {
    @Resource
    private DiscussMapper discussMapper;


    @Override
    public List<Discuss> discuss(String mid, String lid) {
        return discussMapper.discuss(mid,lid);
    }

    @Override
    public DefaultMsg discuessMe(Discuss discuss) {
        DefaultMsg defaultMsg = new DefaultMsg();
        Date date = new Date();
        SimpleDateFormat simpleDateFormat=new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
        String format=simpleDateFormat.format(date);
        discuss.setCreateDate(format);
        int i = discussMapper.discuessMe(discuss);

        if(i!=1){
            defaultMsg.setSuccess(0);
            defaultMsg.setMsg("异常");
        }
        return defaultMsg;
    }
}
